export const actions = {
  async nuxtServerInit({commit}, {req, app}) {
    const {status,data:{province,city}} = await app.$axios.get('/geo/getPosition')
    commit('geo/setPosition', status===200? {city,province} : {city:'',province:''} )

    const {status:stat,data:{menu}} = await  app.$axios.get('/geo/getmenu')
    commit('home/setmenu', stat===200? menu : [] )

    let acity = city.replace('市','')

    const {status:stats,data:{result}} = await  app.$axios.get('/search/hotPlace', {
      params: {
        city: acity
      }
    })
    commit('home/sethotPlace', stat===200? result : [] )

    const {status:statsm,data:{pois}} = await  app.$axios.get('/search/resultsByKeywords', {
      params: {
        city: acity,
        keyword: '酒店'
      }
    })
    commit('home/setInithotelList', statsm===200? pois : [] )


    const {status:statu,data:{hots}} = await app.$axios.get('/geo/hotCity')
    let hotCity = hots.map((item) => {
      if (item.name === '市辖区') {
        return item.province
      }else return item.name
    })
    commit('geo/sethotCity', status===200? hotCity : [] )

    const {status:statsmm,data:{pois: poi}} = await  app.$axios.get('/search/resultsByKeywords', {
      params: {
        city: acity,
        keyword: '景点'
      }
    })
    commit('home/setyoulikeline1', statsmm===200? poi : [] )

    // const {status:statsmmm,data:{pois:poim}} = await  app.$axios.get('/search/resultsByKeywords', {
    //   params: {
    //     city: acity,
    //     keyword: '吃'
    //   }
    // })
    // commit('home/setyoulikeline2', statsmmm===200? poim : [] )
    //
    // const {status:statsmmmm,data:{pois:poimm}} = await  app.$axios.get('/search/resultsByKeywords', {
    //   params: {
    //     city: acity,
    //     keyword: '玩'
    //   }
    // })
    // commit('home/setyoulikeline3', statsmmmm===200? poimm : [] )

  }
}

